package com.example.mvc.controller;

import com.example.mvc.bean.History;
import com.example.mvc.service.BookBorrowService;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.util.List;

//借和还的列表
@WebServlet("/bookBorrowReturnedHistoryListServlet")
public class BookBorrowReturnedHistoryListServlet  extends HttpServlet {
    BookBorrowService bookBorrowService = new BookBorrowService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        List<History> bookHistoryStatusList = bookBorrowService.bookHistoryList();
        HttpSession session = req.getSession();
        session.setAttribute("bookHistoryStatusList",bookHistoryStatusList);
        String contextPath = req.getContextPath();
        resp.sendRedirect(contextPath+"/admin_blog.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
